#include "login.h"
#include "ui_login.h"
#include "mainwindow.h"
#include <QDebug>
#include <QMessageBox>

Login::Login(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::Login)
{
    ui->setupUi(this);
}

Login::~Login()
{
    delete ui;
}



void Login::on_loginButton_clicked()
{
    QString username = ui->lineEditUser->text();
    QString password = ui->lineEditPass->text();

        // 简单验证
        if (username == "admin" && password == "admin") {
            MainWindow *mainWindow = new MainWindow(this);
            mainWindow->move(this->x(),this->y());
            mainWindow->show();
            qDebug() << "success";
            this->hide();
        } else {
            ui->lineEditUser->setText("");
            ui->lineEditPass->setText("");
            QMessageBox::warning(this, "错误", "错误账号或密码错误");
        }
}

